import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { UserRouteAccessService } from './core'

import { P404Component } from './common/error/404.component'

// Import Containers
import {
  FullLayoutComponent,
  SimpleLayoutComponent,
  SimpleNavLayoutComponent
} from './containers';

export const routes: Routes = [
  {
    path: '',
    redirectTo: 'dashboard',
    pathMatch: 'full',
  },
  {
    path: '',
    component: SimpleNavLayoutComponent,
    data: {
      title: 'Home'
    },
    children: [
      {
        path: 'dashboard',
        data: {
            authorities: ['ROLE_ADMIN']
        },
        canActivate: [UserRouteAccessService],
        loadChildren: './views/dashboard/dashboard.module#DashboardModule'
      },
      {
        path: 'common',
        data: {
          title: '我的账户'
        },
        loadChildren: './common/common.module#DeliverCommonModule'
      },
      {
        path: 'admin',
        data: {
            authorities: ['ROLE_ADMIN']
        },
        canActivate: [UserRouteAccessService],
        // canLoad: [],
        loadChildren: './admin/admin.module#DeliverApplicationAdminModule'
      },
      {
        path: 'entity',
        data: {
            authorities: ['ROLE_ADMIN']
        },
        loadChildren: './entities/entity.module#DeliverApplicationEntityModule'
      }
    ]
  },
  { path: '**', component: P404Component }
];

@NgModule({
  imports: [ RouterModule.forRoot(routes, { enableTracing: true }) ],
  exports: [ RouterModule ]
})
export class AppRoutingModule {}
